{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "df665d24-f3ff-4f9b-951c-0831027434a4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"skoriQ\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.4.0/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"skoriQ\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"skoriQ\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "Lets-Plot Kotlin API v.0.0.0-SNAPSHOT. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.4.0."
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "\n",
    "LetsPlot.getInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6b451621-29e1-446d-ab57-11557cc7001f",
   "metadata": {},
   "outputs": [],
   "source": [
    "val data1 = mapOf(\n",
    "    \"x\" to listOf(\"A\", \"B\", \"C\", \"D\", \"E\"),\n",
    "    \"y\" to listOf(300, -100, -400, 300, 200),\n",
    ")\n",
    "\n",
    "val data2 = mapOf(\n",
    "    \"x\" to listOf(\"A\", \"B\", \"C\", \"D\", \"T1\", \"A\", \"B\", \"C\", \"D\", \"T2\"),\n",
    "    \"y\" to listOf(100, 100, -300, 500, null, -200, 300, 100, -300, 0.0),\n",
    "    \"m\" to listOf(\"relative\", \"relative\", \"relative\", \"relative\", \"total\", \"relative\", \"relative\", \"relative\", \"relative\", \"total\"),\n",
    ")\n",
    "\n",
    "val data3 = mapOf(\n",
    "    \"x\" to listOf(\"A\", \"B\", \"C\", \"D\", \"E\", \"A\", \"B\", \"C\", \"D\", \"T\"),\n",
    "    \"y\" to listOf(100, 100, -300, 500, 300, -200, 300, 100, -300, 0.0),\n",
    "    \"m\" to listOf(\"absolute\", \"relative\", \"relative\", \"relative\", \"absolute\", \"relative\", \"relative\", \"relative\", \"relative\", \"total\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c07f677e-77e0-4dc1-a75c-23d9019108ae",
   "metadata": {},
   "source": [
    "## Default"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7644c9c6-6d53-48ae-b1dc-4bf8f69948ba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"GeJ1u1\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":3,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"Without absolute\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"With absolute\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"A\",\"B\",\"C\",\"D\",\"T\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,200.0,200.0,400.0,null,300.0,400.0,500.0,500.0,null],\n",
       "\"..ymin..\":[null,100.0,-100.0,-100.0,null,100.0,100.0,400.0,200.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0],\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,null,null,null,300.0,null,null,null,null,200.0],\n",
       "\"..ymin..\":[0.0,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,150.0,200.0,250.0,450.0,350.0,100.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"GeJ1u1\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\") + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\") + ggtitle(\"With measure\", \"Without absolute\"),\n",
    "    waterfallPlot(data3, \"x\", \"y\", measure = \"m\") + ggtitle(\"With measure\", \"With absolute\"),\n",
    "))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b9d7af9a-90f5-4df6-b013-d9699bdb1bb8",
   "metadata": {},
   "source": [
    "## Parameters"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "70c8d128-ac15-48ea-97c0-4393bee16ef4",
   "metadata": {},
   "source": [
    "### Aesthetics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "edf96788-7da9-45c7-adc1-dce41a7b8ef2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"gQxgyc\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"color\":\"..flow_type..\"\n",
       "},\n",
       "\"fill\":\"lightgrey\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"color\":\"..flow_type..\"\n",
       "},\n",
       "\"fill\":\"lightgrey\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"color\":\"..flow_type..\"\n",
       "},\n",
       "\"fill\":\"lightgrey\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"color\":\"..flow_type..\"\n",
       "},\n",
       "\"fill\":\"lightgrey\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"gQxgyc\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// color\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", size = 1.0, color = \"magenta\") + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data1, \"x\", \"y\", size = 1.0, color = \"flow_type\", fill = \"lightgrey\") + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", size = 1.0, color = \"magenta\") + ggtitle(\"With measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", size = 1.0, color = \"flow_type\", fill=\"lightgrey\") + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "82e01445-ff41-4ff0-9a1f-502dc66fb3ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"qeR33p\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"magenta\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"qeR33p\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// fill\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", size = 1.0, fill = \"magenta\") + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", size = 1.0, fill = \"magenta\") + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "6e9ea88a-ac8a-4734-b691-79eda73a8088",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"CFEw1i\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":2.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":2.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":2.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":2.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"CFEw1i\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// size\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", size = 2.0) + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", size = 2.0) + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "78833028-8bb0-458a-8766-209652949fe3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"Ra9x4F\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"alpha\":0.5,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"alpha\":0.5,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"alpha\":0.5,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"alpha\":0.5,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"Ra9x4F\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// alpha\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", alpha = 0.5) + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", alpha = 0.5) + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "82652fb9-fb77-4594-9c2b-4d8482408e38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"FNo42I\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":2,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":2,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":2,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":2,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"FNo42I\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// linetype\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", size = 1.0, linetype = \"dashed\") + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", size = 1.0, linetype = \"dashed\") + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "7f890eb2-9ad0-4f13-835f-7724f55166ba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"xIFFnA\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.6,0.6,0.6,0.6,0.6,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.2\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.4,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.4,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.2\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.4,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.4,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"xIFFnA\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// width\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", width = 0.4) + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.4) + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5b1b6836-d21d-42b1-ba1e-0a453db9ecdb",
   "metadata": {},
   "source": [
    "### Standard parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "423e6840-fbfd-4a06-9ed1-2d5334860cde",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"Q6zCgI\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"Default calcTotal\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"calcTotal = false\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..ymax..\":[null,null,null,null,null],\n",
       "\"..ymin..\":[null,null,null,null,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"Without absolute\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"With absolute\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"A\",\"B\",\"C\",\"D\",\"T\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,200.0,200.0,400.0,null,300.0,400.0,500.0,500.0,null],\n",
       "\"..ymin..\":[null,100.0,-100.0,-100.0,null,100.0,100.0,400.0,200.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0],\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,null,null,null,300.0,null,null,null,null,200.0],\n",
       "\"..ymin..\":[0.0,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,150.0,200.0,250.0,450.0,350.0,100.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"Q6zCgI\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// showLegend\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", showLegend = true, calcTotal = true) + ggtitle(\"Without measure\", \"Default calcTotal\"),\n",
    "    waterfallPlot(data1, \"x\", \"y\", showLegend = true, calcTotal = false) + ggtitle(\"Without measure\", \"calcTotal = false\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", showLegend = true) + ggtitle(\"With measure\", \"Without absolute\"),\n",
    "    waterfallPlot(data3, \"x\", \"y\", measure = \"m\", showLegend = true) + ggtitle(\"With measure\", \"With absolute\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b83ed533-4bef-4942-8fd1-07c1d68bbaa6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"F7Xvgh\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":4,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"Default tooltips\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"tooltips = 'none'\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":\"none\"\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":\"none\"\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"tooltips = 'detailed'\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..initial..\":[0.0,300.0,200.0,-200.0,100.0,0.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel..\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"Initial|@..initial..\",\"Difference|@..dy..\",\"Cumulative sum|@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..initial..\",\n",
       "\"format\":\".2~f\"\n",
       "},{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "},{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel..\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"Value|@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"Custom tooltips\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..initial..\":[0.0,300.0,200.0,-200.0,100.0,0.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel.. (#@..x..)\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@{..flow_type..}d from @..initial.. to @..value..\"]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel.. (#@..x..)\",\n",
       "\"lines\":[\"Absolute value|@..value..\"]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"Default tooltips\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"tooltips = 'none'\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":\"none\"\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":\"none\"\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"tooltips = 'detailed'\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..initial..\":[0.0,100.0,200.0,-100.0,0.0,400.0,200.0,500.0,600.0,400.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel..\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"Initial|@..initial..\",\"Difference|@..dy..\",\"Cumulative sum|@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..initial..\",\n",
       "\"format\":\".2~f\"\n",
       "},{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "},{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel..\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"Value|@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"Custom tooltips\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..initial..\":[0.0,100.0,200.0,-100.0,0.0,400.0,200.0,500.0,600.0,400.0],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel.. (#@..x..)\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@{..flow_type..}d from @..initial.. to @..value..\"]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel.. (#@..x..)\",\n",
       "\"lines\":[\"Absolute value|@..value..\"]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"F7Xvgh\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// tooltips\n",
    "val relativeTooltips = layerTooltips().title(\"@..xlabel.. (#@..x..)\").line(\"@{..flow_type..}d from @..initial.. to @..value..\").disableSplitting()\n",
    "val absoluteTooltips = layerTooltips().title(\"@..xlabel.. (#@..x..)\").line(\"Absolute value|@..value..\")\n",
    "\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\") + ggtitle(\"Without measure\", \"Default tooltips\"),\n",
    "    waterfallPlot(data1, \"x\", \"y\", relativeTooltips = \"none\", absoluteTooltips = \"none\") + ggtitle(\"Without measure\", \"tooltips = 'none'\"),\n",
    "    waterfallPlot(data1, \"x\", \"y\", relativeTooltips = \"detailed\", absoluteTooltips = \"detailed\") + ggtitle(\"Without measure\", \"tooltips = 'detailed'\"),\n",
    "    waterfallPlot(data1, \"x\", \"y\", relativeTooltips = relativeTooltips, absoluteTooltips = absoluteTooltips) + ggtitle(\"Without measure\", \"Custom tooltips\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\") + ggtitle(\"With measure\", \"Default tooltips\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", relativeTooltips = \"none\", absoluteTooltips = \"none\") + ggtitle(\"With measure\", \"tooltips = 'none'\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", relativeTooltips = \"detailed\", absoluteTooltips = \"detailed\") + ggtitle(\"With measure\", \"tooltips = 'detailed'\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", relativeTooltips = relativeTooltips, absoluteTooltips = absoluteTooltips) + ggtitle(\"With measure\", \"Custom tooltips\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "17e7b87f-3624-40ff-9364-67a375514a52",
   "metadata": {},
   "source": [
    "### Waterfall-specific parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "482493d1-d1d8-4478-900d-eae6b4d7efac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"ITlUPn\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"C\",\"A\",\"D\",\"E\",\"B\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[-400.0,-100.0,200.0,400.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Decrease\",\"Increase\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[-400.0,300.0,300.0,200.0,-100.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[0.0,-100.0,200.0,400.0,400.0,null],\n",
       "\"..ymin..\":[-400.0,-400.0,-100.0,200.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[-400.0,-100.0,200.0,400.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Decrease\",\"Increase\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[-200.0,-250.0,50.0,300.0,350.0,150.0],\n",
       "\"..label..\":[-400.0,300.0,300.0,200.0,-100.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"D\",\"C\",\"A\",\"B\",\"T1\",\"B\",\"D\",\"A\",\"C\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[500.0,200.0,300.0,400.0,400.0,700.0,400.0,200.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[500.0,-300.0,100.0,100.0,400.0,300.0,-300.0,-200.0,100.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[500.0,500.0,300.0,400.0,null,700.0,700.0,400.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,200.0,300.0,null,400.0,400.0,200.0,200.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[500.0,200.0,300.0,400.0,400.0,700.0,400.0,200.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[250.0,350.0,250.0,350.0,200.0,550.0,550.0,300.0,250.0,150.0],\n",
       "\"..label..\":[500.0,-300.0,100.0,100.0,400.0,300.0,-300.0,-200.0,100.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"ITlUPn\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// sortedValue\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", sortedValue = true) + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", sortedValue = true) + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7ca5b72f-4e97-4e59-b328-9fa3f4d34fd1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"RsQCKA\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"labels\":[\"A\",\"C\",\"D\",\"Other\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..y..\":[300.0,-100.0,200.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-400.0,300.0,100.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,300.0,null],\n",
       "\"..ymin..\":[0.0,-100.0,-100.0,200.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,-100.0,200.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..ymax..\":[null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..y..\":[150.0,100.0,50.0,250.0,150.0],\n",
       "\"..label..\":[300.0,-400.0,300.0,100.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"labels\":[\"C\",\"D\",\"Other\",\"T1\",\"B\",\"D\",\"Other\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..y..\":[-300.0,200.0,400.0,400.0,700.0,400.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Decrease\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[-300.0,500.0,200.0,400.0,300.0,-300.0,-100.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..ymax..\":[0.0,200.0,400.0,null,700.0,700.0,400.0,null],\n",
       "\"..ymin..\":[-300.0,-300.0,200.0,null,400.0,400.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[-300.0,200.0,400.0,400.0,700.0,400.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Decrease\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..ymax..\":[null,null,null,400.0,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,0.0,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..y..\":[-150.0,-50.0,300.0,200.0,550.0,550.0,350.0,150.0],\n",
       "\"..label..\":[-300.0,500.0,200.0,400.0,300.0,-300.0,-100.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"RsQCKA\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// threshold\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", threshold = 200.0) + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", threshold = 200.0) + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7e8e058a-7665-4b7d-aa75-396519d0124e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"wpBs91\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0],\n",
       "\"labels\":[\"A\",\"C\",\"Other\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0],\n",
       "\"..y..\":[300.0,-100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-400.0,400.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0],\n",
       "\"..ymax..\":[300.0,300.0,300.0,null],\n",
       "\"..ymin..\":[0.0,-100.0,-100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,-100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0],\n",
       "\"..ymax..\":[null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0],\n",
       "\"..y..\":[150.0,100.0,100.0,150.0],\n",
       "\"..label..\":[300.0,-400.0,400.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"labels\":[\"C\",\"D\",\"Other\",\"T1\",\"B\",\"D\",\"Other\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..y..\":[-300.0,200.0,400.0,400.0,700.0,400.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Decrease\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[-300.0,500.0,200.0,400.0,300.0,-300.0,-100.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..ymax..\":[0.0,200.0,400.0,null,700.0,700.0,400.0,null],\n",
       "\"..ymin..\":[-300.0,-300.0,200.0,null,400.0,400.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[-300.0,200.0,400.0,400.0,700.0,400.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Decrease\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..ymax..\":[null,null,null,400.0,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,0.0,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..y..\":[-150.0,-50.0,300.0,200.0,550.0,550.0,350.0,150.0],\n",
       "\"..label..\":[-300.0,500.0,200.0,400.0,300.0,-300.0,-100.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"wpBs91\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// maxValues\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", maxValues = 2) + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", maxValues = 2) + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ab513acb-a1ac-4dd8-836c-63bfddfa9dce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"UrewqZ\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"labels\":[\"a\",\"b\",\"c\",\"d\",\"t\",\"a\",\"b\",\"t\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..y..\":[1.0,-1.0,2.0,2.0,2.0,2.0,4.0,4.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[1.0,-2.0,3.0,0.0,2.0,0.0,2.0,2.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..ymax..\":[1.0,1.0,2.0,2.0,null,2.0,4.0,null],\n",
       "\"..ymin..\":[0.0,-1.0,-1.0,2.0,null,2.0,2.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[1.0,-1.0,2.0,2.0,2.0,2.0,4.0,4.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Increase\",\"Total\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..ymax..\":[null,null,null,null,2.0,null,null,4.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0],\n",
       "\"..y..\":[0.5,0.0,0.5,2.0,1.0,2.0,3.0,2.0],\n",
       "\"..label..\":[1.0,-2.0,3.0,0.0,2.0,0.0,2.0,4.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"a\",\"b\",\"c\",\"t\",\"b\",\"t\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[1.0,-1.0,2.0,2.0,4.0,4.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[1.0,-2.0,3.0,2.0,2.0,2.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[1.0,1.0,2.0,null,4.0,null],\n",
       "\"..ymin..\":[0.0,-1.0,-1.0,null,2.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[1.0,-1.0,2.0,2.0,4.0,4.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,2.0,null,4.0],\n",
       "\"..ymin..\":[null,null,null,0.0,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[0.5,0.0,0.5,1.0,3.0,2.0],\n",
       "\"..label..\":[1.0,-2.0,3.0,2.0,2.0,4.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"UrewqZ\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// Use threshold to skip zeros\n",
    "val dataWithZeros = mapOf(\n",
    "    \"x\" to listOf(\"a\", \"b\", \"c\", \"d\", \"t\", \"a\", \"b\", \"t\"),\n",
    "    \"y\" to listOf(1, -2, 3, 0, null, 0, 2, null),\n",
    "    \"m\" to listOf(\"relative\", \"relative\", \"relative\", \"relative\", \"total\", \"relative\", \"relative\", \"total\"),\n",
    ")\n",
    "\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(dataWithZeros, \"x\", \"y\", measure = \"m\"),\n",
    "    waterfallPlot(dataWithZeros, \"x\", \"y\", measure = \"m\", threshold = 0.0),\n",
    "))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "27315df6-acba-4c7e-81a8-382d172c0c5b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"HNyLA0\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"Default calcTotal\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Total\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\",\n",
       "\"subtitle\":\"calcTotal = false\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..ymax..\":[null,null,null,null,null],\n",
       "\"..ymin..\":[null,null,null,null,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"Default calcTotal\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\",\n",
       "\"subtitle\":\"calcTotal = false\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"HNyLA0\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// calcTotal\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\") + ggtitle(\"Without measure\", \"Default calcTotal\"),\n",
    "    waterfallPlot(data1, \"x\", \"y\", calcTotal = false) + ggtitle(\"Without measure\", \"calcTotal = false\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\") + ggtitle(\"With measure\", \"Default calcTotal\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", calcTotal = false) + ggtitle(\"With measure\", \"calcTotal = false\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "8dde4088-12f9-46ee-a7ee-24d403f4fbec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"ptBzSP\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Without measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Result\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Result\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Result\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[300.0,200.0,-200.0,100.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Result\"],\n",
       "\"..dy..\":[300.0,-100.0,-400.0,300.0,200.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[300.0,300.0,200.0,100.0,300.0,null],\n",
       "\"..ymin..\":[0.0,200.0,-200.0,-200.0,100.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[300.0,200.0,-200.0,100.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Decrease\",\"Decrease\",\"Increase\",\"Increase\",\"Result\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..ymax..\":[null,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,null,0.0],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"Result\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel..\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"Value|@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0],\n",
       "\"..y..\":[150.0,250.0,0.0,-50.0,200.0,150.0],\n",
       "\"..label..\":[300.0,-100.0,-400.0,300.0,200.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"With measure\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Result\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Result\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Result\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Result\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Result\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Result\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0],\n",
       "\"..xlabel..\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"title\":\"@..xlabel..\",\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"Value|@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"ptBzSP\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// totalTitle\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data1, \"x\", \"y\", totalTitle = \"Result\", showLegend = true, absoluteTooltips = \"detailed\") + ggtitle(\"Without measure\"),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", totalTitle = \"Result\", showLegend = true, absoluteTooltips = \"detailed\") + ggtitle(\"With measure\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "931fa8e1-a41c-441b-80f3-1f989c93cb49",
   "metadata": {},
   "source": [
    "### Control additional geometries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "23011d78-8ae8-4fdd-b464-63bc180ac33e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"8aZuTN\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "},{\n",
       "\"geom\":\"hline\",\n",
       "\"yintercept\":0.0,\n",
       "\"linetype\":2,\n",
       "\"tooltips\":\"none\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"8aZuTN\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// hline\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = elementLine()),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = elementLine(blank = true)),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = elementBlank()),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = \"blank\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "45dc28f2-6201-4b78-a762-1c21f5f375a0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"OpGbI2\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"hline\",\n",
       "\"yintercept\":0.0,\n",
       "\"linetype\":2,\n",
       "\"tooltips\":\"none\",\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"OpGbI2\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// hlineOntop\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = elementLine(), hlineOntop = false)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "89e4ade6-097d-4a7e-9808-0813bf0d13b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"UJgQGC\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "},{\n",
       "\"geom\":\"hline\",\n",
       "\"yintercept\":0.0,\n",
       "\"color\":\"magenta\",\n",
       "\"linetype\":2,\n",
       "\"tooltips\":\"none\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"UJgQGC\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// hline color\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = elementLine(color = \"magenta\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "d2315516-af71-4c85-b130-52152e552932",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"8NNnat\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "},{\n",
       "\"geom\":\"hline\",\n",
       "\"yintercept\":0.0,\n",
       "\"size\":2.0,\n",
       "\"linetype\":2,\n",
       "\"tooltips\":\"none\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"8NNnat\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// hline size\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = elementLine(size = 2.0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "e576db23-4b5f-4769-b89a-d64c0fa9e0a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"sfkdN3\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "},{\n",
       "\"geom\":\"hline\",\n",
       "\"yintercept\":0.0,\n",
       "\"linetype\":1,\n",
       "\"tooltips\":\"none\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"sfkdN3\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// hline lineType\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", hline = elementLine(linetype = \"solid\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "9b2a2807-1dd7-48eb-a86f-71b1060d5740",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"N5prtr\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.25\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"N5prtr\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// connector\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.5, connector = elementLine()),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.5, connector = elementLine(blank = true)),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.5, connector = elementBlank()),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.5, connector = \"blank\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "a1de59d7-2937-4797-b13e-39e92e655fb6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"2tLjxn\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.25\n",
       "},\n",
       "\"color\":\"magenta\"\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"2tLjxn\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// connector color\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.5, connector = elementLine(color = \"magenta\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "07bd40bb-5d39-4631-92b6-30e8a68cae57",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"vxNWly\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.25\n",
       "},\n",
       "\"size\":2.0\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"vxNWly\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// connector size\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.5, connector = elementLine(size = 2.0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "9bc7f4b5-aa16-48ab-b78e-ba14aad2878e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"fLAWiq\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.25\n",
       "},\n",
       "\"linetype\":3\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.5,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"fLAWiq\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// connector linetype\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", width = 0.5, connector = elementLine(linetype = \"dotted\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "a22632ff-5c60-4f73-824c-b11bce7d8d74",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"8EmxOc\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"8EmxOc\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// label\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText()),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText(blank = true)),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementBlank()),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = \"blank\"),\n",
    "), ncol = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "36cdc00c-0c1b-4e12-9209-d47780e8d67d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"QcxoCQ\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"yellow\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"lightgray\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"lightgray\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\",\n",
       "\"color\":\"..flow_type..\"\n",
       "},\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"QcxoCQ\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// label color\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText(color = \"yellow\")),\n",
    "    waterfallPlot(data2, \"x\", \"y\", measure = \"m\", fill = \"lightgray\", label = elementText(color = \"flow_type\")),\n",
    "))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "aa2003e8-c4ab-4c62-b21f-085c95f27223",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"FbLajE\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"family\":\"Courier\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"FbLajE\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// label family\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText(family = \"Courier\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "19451de0-2047-468d-87f6-49b79e403186",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"8sZpTt\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"fontface\":\"bold_italic\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"8sZpTt\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// label face\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText(face = \"bold_italic\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "804a2d19-ae3c-4240-9f15-7e4a47c216ba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"McQ8Tm\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"size\":10.0,\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"McQ8Tm\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// label size\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText(size = 10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6216a61b-07c9-4aa0-b9b3-576ec0891585",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"0d4WUW\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"angle\":45.0,\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"0d4WUW\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// label angle\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText(angle = 45))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "24bf8d68-5c24-4652-936b-1fc08af776d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"58pntJ\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"hjust\":0.0,\n",
       "\"vjust\":0.0,\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"58pntJ\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// label hjust/vjust\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", label = elementText(hjust = 0, vjust = 0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "941519f9-f44f-4d27-a67d-7fb51b7ccc0e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"f61VB2\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\"({.1f})\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"f61VB2\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// labelFormat\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\", labelFormat = \"({.1f})\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "b9a522c9-a3f0-4dd9-94bd-ce0e97893115",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"mByESs\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"g\":[\"a\",\"a\",\"a\",\"b\",\"b\",\"b\",\"b\"]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0],\n",
       "\"labels\":[\"A\",\"C\",\"T1\",\"A\",\"B\",\"C\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.0,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0],\n",
       "\"..y..\":[2.0,1.0,1.0,1.0,4.0,2.0,2.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Absolute\",\"Decrease\",\"Total\",\"Absolute\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[2.0,-1.0,1.0,1.0,3.0,-2.0,2.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0],\n",
       "\"..ymax..\":[null,2.0,null,null,4.0,4.0,null],\n",
       "\"..ymin..\":[null,1.0,null,null,1.0,2.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[2.0,1.0,1.0,1.0,4.0,2.0,2.0],\n",
       "\"..flow_type..\":[\"Absolute\",\"Decrease\",\"Total\",\"Absolute\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0],\n",
       "\"..ymax..\":[2.0,null,1.0,1.0,null,null,2.0],\n",
       "\"..ymin..\":[0.0,null,0.0,0.0,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0],\n",
       "\"..y..\":[1.0,1.5,0.5,0.5,2.5,3.0,1.0],\n",
       "\"..label..\":[2.0,-1.0,1.0,1.0,3.0,-2.0,2.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"facet\":{\n",
       "\"name\":\"wrap\",\n",
       "\"dir\":\"h\",\n",
       "\"facets\":\"g\",\n",
       "\"scales\":\"free_x\",\n",
       "\"order\":1.0\n",
       "},\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"g\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"mByESs\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// group\n",
    "val dataWithGroups = mapOf(\n",
    "    \"x\" to listOf(\"A\", \"C\", \"T1\", \"A\", \"B\", \"C\", \"T2\"),\n",
    "    \"y\" to listOf(2, -1, null, 1, 3, -2, 0.0),\n",
    "    \"m\" to listOf(\"absolute\", \"relative\", \"total\", \"absolute\", \"relative\", \"relative\", \"total\"),\n",
    "    \"g\" to listOf(\"a\", \"a\", \"a\", \"b\", \"b\", \"b\", \"b\"),\n",
    ")\n",
    "\n",
    "waterfallPlot(dataWithGroups, \"x\", \"y\", measure = \"m\", group = \"g\") + facetWrap(facets = \"g\", scales = \"free_x\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6445e7d-ff37-421e-807e-3ea6f040e927",
   "metadata": {},
   "source": [
    "## Other Customizations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "dc4d3c7c-d580-48fc-b3f1-cbb3cc233ac1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"gG3tud\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":1,\n",
       "\"nrow\":3,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Custom scaleFillManual()\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"A\",\"B\",\"C\",\"D\",\"T\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"white\",\"black\",\"green\",\"yellow\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.30000000000000004,0.30000000000000004,0.30000000000000004,0.0,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.35\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,200.0,200.0,400.0,null,300.0,400.0,500.0,500.0,null],\n",
       "\"..ymin..\":[null,100.0,-100.0,-100.0,null,100.0,100.0,400.0,200.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"#777777\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.7,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0],\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,null,null,null,300.0,null,null,null,null,200.0],\n",
       "\"..ymin..\":[0.0,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"#777777\",\n",
       "\"size\":1.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.7,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,150.0,200.0,250.0,450.0,350.0,100.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"#777777\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Custom scaleColorManual()\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"A\",\"B\",\"C\",\"D\",\"T\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"green\",\"yellow\",\"red\",\"#bbbbff\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.30000000000000004,0.30000000000000004,0.30000000000000004,0.0,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.35\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,200.0,200.0,400.0,null,300.0,400.0,500.0,500.0,null],\n",
       "\"..ymin..\":[null,100.0,-100.0,-100.0,null,100.0,100.0,400.0,200.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.7,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,null,null,null,300.0,null,null,null,null,200.0],\n",
       "\"..ymin..\":[0.0,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"fill\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.7,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,150.0,200.0,250.0,450.0,350.0,100.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\",\n",
       "\"color\":\"..flow_type..\"\n",
       "},\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Custom flow type names\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"A\",\"B\",\"C\",\"D\",\"T\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Absolute\",\"Total\"],\n",
       "\"values\":[\"green\",\"red\",\"cyan\",\"yellow\"],\n",
       "\"labels\":[\"Up\",\"Down\",\"From zero\",\"Result\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.30000000000000004,0.30000000000000004,0.30000000000000004,0.0,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.30000000000000004,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.35\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,200.0,200.0,400.0,null,300.0,400.0,500.0,500.0,null],\n",
       "\"..ymin..\":[null,100.0,-100.0,-100.0,null,100.0,100.0,400.0,200.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"#777777\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.7,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,300.0,100.0,400.0,500.0,200.0,200.0],\n",
       "\"..flow_type..\":[\"Absolute\",\"Increase\",\"Decrease\",\"Increase\",\"Absolute\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,null,null,null,300.0,null,null,null,null,200.0],\n",
       "\"..ymin..\":[0.0,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"#777777\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.7,\n",
       "\"show_legend\":true,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,150.0,200.0,250.0,450.0,350.0,100.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,300.0,-200.0,300.0,100.0,-300.0,200.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"#777777\",\n",
       "\"show_legend\":true,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":1000.0,\n",
       "\"height\":800.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"gG3tud\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// fill and color\n",
    "gggrid(listOf(\n",
    "    waterfallPlot(data3, \"x\", \"y\", measure = \"m\", showLegend = true, width = 0.7, size = 1.0, color = \"#777777\", label = elementText(color = \"#777777\")) +\n",
    "        scaleFillManual(mapOf(\"Increase\" to \"white\", \"Decrease\" to \"black\", \"Absolute\" to \"green\", \"Total\" to \"yellow\")) +\n",
    "        ggtitle(\"Custom scaleFillManual()\"),\n",
    "    waterfallPlot(data3, \"x\", \"y\", measure = \"m\", showLegend = true, width = 0.7, fill = \"black\", label = elementText(color = \"flow_type\")) +\n",
    "        scaleColorManual(mapOf(\"Increase\" to \"green\", \"Decrease\" to \"yellow\", \"Absolute\" to \"red\", \"Total\" to \"#bbbbff\")) +\n",
    "        ggtitle(\"Custom scaleColorManual()\"),\n",
    "    waterfallPlot(data3, \"x\", \"y\", measure = \"m\", showLegend = true, width = 0.7, color = \"#777777\", label = elementText(color = \"#777777\")) +\n",
    "        scaleFillManual(mapOf(\"Increase\" to \"green\", \"Decrease\" to \"red\", \"Absolute\" to \"cyan\", \"Total\" to \"yellow\"),\n",
    "                        labels = listOf(\"Up\", \"Down\", \"From zero\", \"Result\")) +\n",
    "        ggtitle(\"Custom flow type names\"),\n",
    "), ncol = 1) + ggsize(1000, 800)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "77a4c4f3-ec15-4afd-84a5-1827701cc87f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"5LtcJi\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"coord\":{\n",
       "\"name\":\"flip\",\n",
       "\"flip\":true\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "},\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"5LtcJi\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// flip coordinates\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\") + coordFlip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "27b85478-d5bb-4a71-8923-41f847e33a79",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"IZCGkb\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"x\",\n",
       "\"name\":\"x\",\n",
       "\"breaks\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"labels\":[\"A\",\"B\",\"C\",\"D\",\"T1\",\"A\",\"B\",\"C\",\"D\",\"T2\"]\n",
       "},{\n",
       "\"aesthetic\":\"y\",\n",
       "\"name\":\"y\"\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "},{\n",
       "\"aesthetic\":\"fill\",\n",
       "\"name\":\"Flow type\",\n",
       "\"breaks\":[\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"values\":[\"#4daf4a\",\"#e41a1c\",\"#377eb8\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"geom\":\"spoke\",\n",
       "\"data\":{\n",
       "\"..radius..\":[0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.09999999999999998,0.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"radius\":\"..radius..\"\n",
       "},\n",
       "\"angle\":0.0,\n",
       "\"position\":{\n",
       "\"name\":\"nudge\",\n",
       "\"x\":0.45\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..dy..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,-100.0],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[100.0,200.0,200.0,400.0,null,400.0,500.0,600.0,600.0,null],\n",
       "\"..ymin..\":[0.0,100.0,-100.0,-100.0,null,200.0,200.0,500.0,300.0,null]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"lines\":[\"@..dy..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..dy..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"crossbar\",\n",
       "\"data\":{\n",
       "\"..value..\":[100.0,200.0,-100.0,400.0,400.0,200.0,500.0,600.0,300.0,300.0],\n",
       "\"..flow_type..\":[\"Increase\",\"Increase\",\"Decrease\",\"Increase\",\"Total\",\"Decrease\",\"Increase\",\"Increase\",\"Decrease\",\"Total\"],\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..ymax..\":[null,null,null,null,400.0,null,null,null,null,300.0],\n",
       "\"..ymin..\":[null,null,null,null,0.0,null,null,null,null,0.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"ymin\":\"..ymin..\",\n",
       "\"ymax\":\"..ymax..\",\n",
       "\"fill\":\"..flow_type..\"\n",
       "},\n",
       "\"color\":\"black\",\n",
       "\"size\":0.0,\n",
       "\"linetype\":1,\n",
       "\"width\":0.9,\n",
       "\"show_legend\":false,\n",
       "\"tooltips\":{\n",
       "\"disable_splitting\":true,\n",
       "\"lines\":[\"@..value..\"],\n",
       "\"formats\":[{\n",
       "\"field\":\"..value..\",\n",
       "\"format\":\".2~f\"\n",
       "}]\n",
       "}\n",
       "},{\n",
       "\"geom\":\"text\",\n",
       "\"data\":{\n",
       "\"..x..\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],\n",
       "\"..y..\":[50.0,150.0,50.0,150.0,200.0,300.0,350.0,550.0,450.0,150.0],\n",
       "\"..label..\":[100.0,100.0,-300.0,500.0,400.0,-200.0,300.0,100.0,-300.0,300.0]\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"..x..\",\n",
       "\"y\":\"..y..\",\n",
       "\"label\":\"..label..\"\n",
       "},\n",
       "\"color\":\"white\",\n",
       "\"show_legend\":false,\n",
       "\"label_format\":\".2~f\"\n",
       "}],\n",
       "\"theme\":{\n",
       "\"axis_tooltip\":\"blank\",\n",
       "\"name\":\"bw\",\n",
       "\"flavor\":\"darcula\"\n",
       "},\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"m\"\n",
       "}]\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"IZCGkb\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// custom theme\n",
    "waterfallPlot(data2, \"x\", \"y\", measure = \"m\") + themeBW() + flavorDarcula()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "codemirror_mode": "text/x-kotlin",
   "file_extension": ".kt",
   "mimetype": "text/x-kotlin",
   "name": "kotlin",
   "nbconvert_exporter": "",
   "pygments_lexer": "kotlin",
   "version": "1.9.23"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
